// 后台路由

const express = require('express');
const router = express.Router();

//引入后台控制器
const adminController = require('../controllers/adminController');

router.get('/',adminController.index);

router.get('/login',adminController.loginPage);

router.post('/login',adminController.login);

router.get('/logout',adminController.loginout);



//-------------菜单管理------------------
//菜单页面
router.get('/menu',adminController.menuPage)
// -------------文章管理路由-------------


router.get('/article',adminController.articlePage);

router.get('/articleAdd',adminController.articleAddPage);

router.post('/articleAdd',adminController.articleAdd);

router.get('/articleEdit/:id',adminController.articleEditPage);

router.post('/articleEdit',adminController.articleEdit);

router.get('/articleDelete/:id',adminController.articleDelete);


//-------------用户管理路由-------------
router.get('/listuser',adminController.listuser);

router.get('/addUser',adminController.addUserPage);

router.post('/addUser',adminController.addUser);

router.get('/deleteUser/:id',adminController.deleteUser);

router.get('/editUser/:id',adminController.getOneuser);

router.post('/edit',adminController.editUser);




// -------------------轮播图模块----------------
const uploadFs = require('../public/upload');

router.get('/banner',adminController.getAllBanner);

router.get('/addBanner',adminController.addBannerPage);

router.post('/addBanner',uploadFs.single('banner'),adminController.addBanner);

router.get('/editBanner/:id',adminController.editBannerPage);

router.post('/editBanner',uploadFs.single('banner'),adminController.editBanner);

router.get('/deleteBanner/:id',adminController.deleteBanner)


//新增菜单
router.get('/addMenuPage',adminController.addMenuPage)
//提交新增菜单
router.post('/addMenu',adminController.addMenu)

//编辑菜单
router.get('/editMenuPage/:id',adminController.editMenuPage)
//提交编辑后的数据
router.post('/editMenu',adminController.editMenu)

//删除菜单
router.get('/deleteMenu/:id',adminController.deleteMenu)

//----------------------文章分类------------------
//显示页面
router.get('/class',adminController.classPage)

//添加 文章
router.get('/addClassPage',adminController.addClassPage)
//提交添加的文章
router.post('/addClass',adminController.addClass)

//编辑文章
router.get('/editClassPage/:id',adminController.editClassPage)

//提交编辑文章
router.post('/editClass',adminController.editClass)

//删除文章
router.get('/deleteClass/:id',adminController.deleteClass)
module.exports = router;